// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2009-10-26 21:57:27


// Source File Name:   LineNumberTable.java

package com.vhly.classfile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;

// Referenced classes of package com.vhly.classfile:
//            LineNumber, Attribute, Debug

public class LineNumberTable
        implements Attribute {

    private int name_index;
    private int data_len;
    private Vector lns;
    private int ln_count;

    public LineNumberTable() {
        ln_count = 0;
        lns = new Vector();
    }

    public LineNumberTable(int i) {
        ln_count = i;
        lns = new Vector();
    }

    public void setNameIndex(int i) {
        name_index = i;
    }

    public int getNameIndex() {
        return name_index;
    }

    public void setDataLen(int i) {
        data_len = i;
    }

    public int getDataLen() {
        return data_len;
    }

    public void read(DataInputStream datainputstream, boolean flag)
            throws IOException {
        if (flag)
            name_index = datainputstream.readUnsignedShort();
        data_len = datainputstream.readInt();
        ln_count = datainputstream.readUnsignedShort();
        for (int i = 0; i < ln_count; i++) {
            LineNumber linenumber = new LineNumber();
            linenumber.read(datainputstream);
            lns.add(linenumber);
        }

    }

    public void write(DataOutputStream dataoutputstream)
            throws IOException {
        dataoutputstream.writeShort(name_index);
        if (Debug.isEnabled())
            System.out.println((new StringBuilder()).append("Write Attribute NameIndex:").append(name_index).toString());
        dataoutputstream.writeInt(data_len);
        dataoutputstream.writeShort(ln_count);
        for (int i = 0; i < ln_count; i++) {
            LineNumber linenumber = (LineNumber) lns.elementAt(i);
            linenumber.write(dataoutputstream);
        }

    }

    public int getType() {
        return 4;
    }
}